// Heracle, Guild NPC
// Author: DejaVu

void npc(Player @player, NPC @npc) {
	int state = npc.getState();
	int selection = npc.getSelected();
	if(state == 0){
		npc.addText("What would you like to do? \r\n\t#b#L0#Create a Guild #l\r\n\t#L1#Disband your Guild #l\r\n\t#L2#Increase your Guild's capacity#l");
		npc.sendSimple();
	}
	else if(state == 1){
		npc.setVariable("selection", selection);
		if(selection == 0){
		/*	if(player.getGuild().getID() < 1){
				npc.addText("You may not create a new Guild while you are in one.");
				npc.sendOK();
				npc.end(); */
		//	} else {
				npc.addText("Creating a Guild costs #b1500000 mesos#k, are you sure you want to continue?");
				npc.sendYesNo();
		//	} 
		}
		else if(selection == 1){
			if(player.getGuildRank() == 1){
				npc.addText("Disbanding your Guild costs #b5000000 mesos#k, are you sure you want to continue?");
				npc.sendYesNo();
			} else {
				npc.addText("You are not the Guild leader, so you cannot disband.");
				npc.sendOK();
				npc.end();
			}
		}
		else if(selection == 2){
			if(player.getGuildRank() == 1){
				if(player.getGuild().getCapacity() >= 100){
					npc.addText("Your Guild can already hold the maximum amount of people.");
					npc.sendOK();
					npc.end();
				}
				else if(player.getGuild().getCapacity() == 10){
					npc.addText("Increasing your Guild's capacity by #b5#k costs #b500000 mesos#k, are you sure you want to continue?");
					npc.sendYesNo();
				}
				else if(player.getGuild().getCapacity() == 15){
					npc.addText("Increasing your Guild's capacity by #b5#k costs #b1500000 mesos#k, are you sure you want to continue?");
					npc.sendYesNo();
				}
				else if(player.getGuild().getCapacity() == 20){
					npc.addText("Increasing your Guild's capacity by #b5#k costs #b2500000 mesos#k, are you sure you want to continue?");
					npc.sendYesNo();
				}
				else if(player.getGuild().getCapacity() == 25){
					npc.addText("Increasing your Guild's capacity by #b5#k costs #b3500000 mesos#k, are you sure you want to continue?");
					npc.sendYesNo();
				} else {
					npc.addText("Increasing your Guild's capacity by #b5#k costs #b5000000 mesos#k, are you sure you want to continue?");
					npc.sendYesNo();
				}
			} else {
				npc.addText("You cannot increase a Guild's capacity if you are not the Guild leader.");
				npc.sendOK();
				npc.end();
			}
		} else {
			npc.end();
		}
	}
	else if(state == 2){
		selection = npc.getVariable("selection");
		if(selection == 0){
			if(npc.getSelected() == YES){
				if(player.getMesos() < 1500000){
					npc.addText("Creating a Guild costs #b1500000 mesos#k.");
					npc.sendOK();
					npc.end();
				} else {
					npc.createGuild();
					npc.end();
				}
			} else {
				npc.end();
			}
		}
		else if(selection == 1){
			if(npc.getSelected() == YES){
				if(player.getMesos() < 5000000){
					npc.addText("Disbanding a Guild costs #b5000000 mesos#k.");
					npc.sendOK();
					npc.end();
				} else {
					npc.disbandGuild();
					player.giveMesos(-5000000);
					npc.end();
				}
			} else {
				npc.end();
			}
		}
		else if(selection == 2){
			if(npc.getSelected() == YES){
				if(player.getGuild().getCapacity() == 10){
					if(player.getMesos() < 500000){
						npc.addText("It costs #b500000 mesos#k to increase your Guild's capacity.");
						npc.sendOK();
						npc.end();
					} else {
						player.giveMesos(-500000);
						npc.increaseGuildCapacity();
						npc.end();
					}
				}
				else if(player.getGuild().getCapacity() == 15){
					if(player.getMesos() < 1500000){
						npc.addText("It costs #b1500000 mesos#k to increase your Guild's capacity.");
						npc.sendOK();
						npc.end();
					} else {
						player.giveMesos(-1500000);
						npc.increaseGuildCapacity();
						npc.end();
					}
				}
				else if(player.getGuild().getCapacity() == 20){
					if(player.getMesos() < 2500000){
						npc.addText("It costs #b2500000 mesos#k to increase your Guild's capacity.");
						npc.sendOK();
						npc.end();
					} else {
						player.giveMesos(-2500000);
						npc.increaseGuildCapacity();
						npc.end();
					}
				}
				else if(player.getGuild().getCapacity() == 25){
					if(player.getMesos() < 3500000){
						npc.addText("It costs #b3500000 mesos#k to increase your Guild's capacity.");
						npc.sendOK();
						npc.end();
					} else {
						player.giveMesos(-3500000);
						npc.increaseGuildCapacity();
						npc.end();
					}
				} else {
					if(player.getMesos() < 5000000){
						npc.addText("It costs #b5000000 mesos#k to increase your Guild's capacity.");
						npc.sendOK();
						npc.end();
					} else {
						player.giveMesos(-5000000);
						npc.increaseGuildCapacity();
						npc.end();
					}
				}
			} else {
				npc.end();
			}
		} else {
			npc.end();
		}
	} else {
		npc.addText("Come back when you are ready.");
		npc.sendOK();
		npc.end();
	}
}